package cn.tedu.api;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

public class Test4_List {
    public static void main(String[] args) {
        List<Double> list = new ArrayList<>();

        list.add(1.1);
        list.add(2.2);
        list.add(3.3);
        list.add(3.3);
        list.add(null);
        list.add(null);
        System.out.println(list);

        list.add(3,9.9);
        System.out.println(list);
        System.out.println(list.get(0));
        System.out.println(list.indexOf(3.3));
        System.out.println(list.lastIndexOf(3.3));

        System.out.println(list.remove(6));
        System.out.println(list.set(5,4.4));
        System.out.println(list);

        List<Double> list2 = list.subList(1,4);
        System.out.println(list2);

        Iterator<Double> it = list.iterator();
        while (it.hasNext()){
            System.out.print(it.next() + "    ");
        }
        ListIterator<Double> it2 = list.listIterator();
        while (it2.hasNext()){
            System.out.print(it2.next() + "   ");
        }
        System.out.println();
        for (int i = 0; i < list.size(); i++) {
            System.out.print(list.get(i) + "    ");
        }
        System.out.println();

        for (Double i : list) {
            System.out.print(i + "    ");
        }
    }
}
